package com.gpframework.module.controller.wages;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.gpframework.module.wages.domain.vo.GzSalaryLevelTransferWarehouseWorkersVo;
import com.gpframework.module.wages.domain.vo.GzWarehouseEvaluationVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gpframework.common.annotation.Log;
import com.gpframework.common.core.controller.BaseController;
import com.gpframework.common.core.domain.AjaxResult;
import com.gpframework.common.enums.BusinessType;
import com.gpframework.module.wages.domain.GzWarehouseWorkerSalaryLevel;
import com.gpframework.module.wages.domain.vo.GzWarehouseWorkerSalaryLevelVo;
import com.gpframework.module.wages.domain.req.GzWarehouseWorkerSalaryLevelReq;
import com.gpframework.module.wages.domain.req.GzWarehouseWorkerSalaryLevelAdd;
import com.gpframework.module.wages.domain.req.GzWarehouseWorkerSalaryLevelUpdate;
import com.gpframework.module.wages.service.IGzWarehouseWorkerSalaryLevelService;
import com.gpframework.common.utils.poi.ExcelUtil;
import javax.validation.Valid;
import io.swagger.annotations.*;
import com.gpframework.common.core.page.TableDataInfo;
/**
 * @ClassName GzWarehouseWorkerSalaryLevelController
 * @Author gpframework
 * @Date 2024-01-18
 * @Version 1.0.0
 * @Description 仓储中心员工资级别Controller
 */
@Validated
@Api(tags = "仓储中心员工资级别")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@SuppressWarnings({"rawtypes","unchecked"})
@RequestMapping("/wages/warehouseworkersalarylevel" )
public class GzWarehouseWorkerSalaryLevelController extends BaseController {

    private final IGzWarehouseWorkerSalaryLevelService iGzWarehouseWorkerSalaryLevelService;

 /**
  * @Description 分页
  * @Author gpframework
  * @Date 2024-01-18
  * @Param gzWarehouseWorkerSalaryLevel
  * @Return TableDataInfo
 */
    @ApiOperation("列表")
    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:list')")
    @GetMapping("/list")
    public TableDataInfo<GzWarehouseWorkerSalaryLevelVo> list(GzWarehouseWorkerSalaryLevelReq gzWarehouseWorkerSalaryLevelReq)
    {
        startPage();
        QueryWrapper<GzWarehouseWorkerSalaryLevel> lqw = new QueryWrapper<GzWarehouseWorkerSalaryLevel>();
        gzWarehouseWorkerSalaryLevelReq.generatorQuery(lqw,true);
        List<GzWarehouseWorkerSalaryLevelVo> list = iGzWarehouseWorkerSalaryLevelService.listVo(lqw);
        return getDataTable(list);
    }

    /**
     * @Description 新增
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzWarehouseWorkerSalaryLevel
     * @Return TableDataInfo
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:add')" )
    @Log(title = "添加仓储中心员工资级别" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody GzWarehouseWorkerSalaryLevelAdd gzWarehouseWorkerSalaryLevelAdd) {
        GzWarehouseWorkerSalaryLevel gzWarehouseWorkerSalaryLevel = Convert.convert(new TypeReference<GzWarehouseWorkerSalaryLevel>() {}, gzWarehouseWorkerSalaryLevelAdd);
        return toAjax(iGzWarehouseWorkerSalaryLevelService.save(gzWarehouseWorkerSalaryLevel) ? 1 : 0);
    }

    /**
     * @Description 修改
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzWarehouseWorkerSalaryLevel
     * @Return TableDataInfo
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:edit')" )
    @Log(title = "修改仓储中心员工资级别" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody GzWarehouseWorkerSalaryLevelUpdate gzWarehouseWorkerSalaryLevelUpdate) {
        GzWarehouseWorkerSalaryLevel gzWarehouseWorkerSalaryLevel = Convert.convert(new TypeReference<GzWarehouseWorkerSalaryLevel>() {}, gzWarehouseWorkerSalaryLevelUpdate);
        return toAjax(iGzWarehouseWorkerSalaryLevelService.updateById(gzWarehouseWorkerSalaryLevel) ? 1 : 0);
    }


    /**
     * @Description 导出
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzWarehouseWorkerSalaryLevel
     * @Return TableDataInfo
     */

    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:export')" )
    @Log(title = "导出仓储中心员工资级别" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(GzWarehouseWorkerSalaryLevelReq gzWarehouseWorkerSalaryLevelReq) {
        QueryWrapper<GzWarehouseWorkerSalaryLevel> lqw = new QueryWrapper<GzWarehouseWorkerSalaryLevel>();
        gzWarehouseWorkerSalaryLevelReq.generatorQuery(lqw,true);
        List<GzWarehouseWorkerSalaryLevelVo> list = iGzWarehouseWorkerSalaryLevelService.listVo(lqw);
        ExcelUtil<GzWarehouseWorkerSalaryLevelVo> util = new ExcelUtil<GzWarehouseWorkerSalaryLevelVo>(GzWarehouseWorkerSalaryLevelVo. class);
        return util.exportExcel(list, "warehouseworkersalarylevel" );
    }

    /**
     * @Description 详情
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzWarehouseWorkerSalaryLevel
     * @Return TableDataInfo
     */
    @ApiOperation("详情")
    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult<GzWarehouseWorkerSalaryLevelVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iGzWarehouseWorkerSalaryLevelService.getVoById(id));
    }



    /**
     * @Description 删除
     * @Author gpframework
     * @Date 2024-01-18
     * @Param gzWarehouseWorkerSalaryLevel
     * @Return TableDataInfo
     */
    @ApiOperation("删除")
    @PreAuthorize("@ss.hasPermi('wages:warehouseworkersalarylevel:remove')" )
    @Log(title = "删除仓储中心员工资级别" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iGzWarehouseWorkerSalaryLevelService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }

    public static void main(String[] args) {
        BigDecimal totalSalary =new BigDecimal("5");
        totalSalary=totalSalary.add(new BigDecimal("-5"));
        System.out.print(totalSalary);

    }
}
